#include <iostream>
#include <stack>

using namespace std;

int main(int argc, char * argv[])
{
	const int MAX = 21;
	char room[MAX][MAX];
	bool visited[MAX][MAX];
	typedef pair<int, int> Int_Pair;
	stack<Int_Pair> black;
	int W, H;
	scanf("%d %d", &W, &H);
	while (W != 0 && H != 0) {
		int i = 0, j = 0;
		int xPos = 0, yPos = 0;
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				scanf("%1s", (*(room + i)) + j);
				if (room[i][j] == '@') {
					xPos = j;
					yPos = i;
				}
			}
		}
		
		for (i = 0; i < MAX; i++) {
			memset(visited + i, false, MAX);
		}
		int tiles = 0;
		black.push(Int_Pair(xPos, yPos));
		visited[yPos][xPos] = true;
		while (!black.empty()) {
			Int_Pair tile = black.top();
			black.pop();
			++tiles;
			
			int reach = tile.first > 0 ? tile.first - 1 : 0;
			if (room[tile.second][reach] == '.' && !visited[tile.second][reach]) {
				black.push(Int_Pair(reach, tile.second));
				visited[tile.second][reach] = true;
			}

			reach = tile.first < W - 1 ? tile.first + 1 : W - 1;
			if (room[tile.second][reach] == '.' && !visited[tile.second][reach]) {
				black.push(Int_Pair(reach, tile.second));
				visited[tile.second][reach] = true;
			}

			reach = tile.second > 0 ? tile.second - 1 : 0;
			if (room[reach][tile.first] == '.' && !visited[reach][tile.first]) {
				black.push(Int_Pair(tile.first, reach));
				visited[reach][tile.first] = true;
			}

			reach = tile.second < H - 1 ? tile.second + 1 : H - 1;
			if (room[reach][tile.first] == '.' && !visited[reach][tile.first]) {
				black.push(Int_Pair(tile.first, reach));
				visited[reach][tile.first] = true;
			}			
		}

		printf("%d\n", tiles);
		

		scanf("%d %d", &W, &H);
	}
	return 0;
}